class Person {
  String name = '张三';
  int age = 23;


  //默认构造方法,只能定义一个
  Person(this.name, this.age);

  //命名构造函数,可以写多个
  Person.setInfo(String name, int age){
    this.name = name;
    this.age = age;
  }

  Person.now(String name, int age){
    print('命名构造函数2');
    this.name = name;
    this.age = age;
  }



  void getInfo() {
    print('${this.name} -------- ${this.age}');
  }
}

void main() {
  var p = Person.setInfo('王五', 22);
  p.getInfo();

  var p2 = Person.now('赵六', 22);
  p2.getInfo();
}
